﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>THẾ GIỚI LINH KIỆN MÁY TÍNH-XUÂN TUẤN</title>
<style>
a {text-decoration: none}
</style>
</head><body>

<body><div align="center">
        <p><font size="+2"><b>Sửa thông tin Loại sản phẩm</b></font></p>
       <br>
              <?php
	  	error_reporting(0);
	 $maloai=$_REQUEST[maloai];
	 $con=mysql_connect("localhost","root","");
	  mysql_select_db("linhkienmt",$con);
	  $sql="select * from loaisp where maloai='".$maloai."'";
	  $kq=mysql_query($sql,$con);
	  $row=mysql_fetch_array($kq);
	  ?>
        </p>
<form method=post action="sualoaisanpham.php">
          <table width="323" height="157" border="1" cellpadding="0" cellspacing="0" >
            <tr>
      <td width="101">Loại sản phẩm:</td>
      <td width="212"><select name="maloai" size=1>
             <?php
	  $con=mysql_connect("localhost","root","");
       mysql_select_db("linhkienmt",$con);
	    $sql="select * from loaisp";
	    $kq=mysql_query($sql,$con);
		$n=mysql_num_rows($kq);
	    if (mysql_num_rows($kq)<>0)
		{
			while ($row=mysql_fetch_row($kq))
			{
				$maloai=$row[0];
				$tenloai=$row[1];
				echo "<option value='$maloai'>$maloai</option>";
			}
		}
	  ?>
      </select></td>
    </tr>
            <tr>
              <td height="34"   align="left"><div align="right">Tên Loại :</div></td>
              <td width="212" align="left" ><input type="text" name="tenloai" size="25" value="<?php echo $row['tenloai'];?>" />              </td>
            </tr>
                       <td height="9" colspan="3"></td>
            </tr>
            <tr>
              <td align="right"><input type="submit" name="sua" value="   Sửa   " />              </td>
              <td ><input type="reset" name="btt_reset" value="   Reset   " /></td>
              <td width="2" >&nbsp;</td>
            </tr>
    </table>
          <br>
  </form>
        
        
          <?php
if ($_REQUEST['sua']!="")
{
$maloai=$_REQUEST[maloai];
$tenloai=$_REQUEST[tenloai];
$con=mysql_connect("localhost","root","");
mysql_select_db("linhkienmt",$con);
$sql2= "update loaisp set maloai='$maloai',tenloai='$tenloai'";
$result=mysql_query($sql2,$con);		
echo"<h4 align='center'>Đã sửa thành công 1 bản ghi</h4>";
echo "</table>";
mysql_close($con);
}
echo "Bấm <a href='xemloaisp.php'><b>vào đây</b></a> để quay trở lại!";
?>
        
</div></body>
</html>
